package com.s69.ssm.service;

import com.s69.ssm.entity.Skill;
import com.s69.ssm.mapper.SkillMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class SkillService {
    @Autowired
    private SkillMapper skillMapper;

    @Transactional
    public void delByStuId(Integer stuId) {
        skillMapper.delByStuId(stuId);
    }

    @Transactional
    public void insert(Integer stuId, List<Skill> skillList) {
        for (Skill skill : skillList) {
            if (StringUtils.hasText(skill.getSname())) {
                skill.setUid(stuId);
                skillMapper.add(skill);
            }
        }
    }
}
